# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=angle-grinder
pkgver=0.19.0
pkgrel=1
pkgdesc="Slice and dice logs on the command line"
arch=('loong64' 'x86_64')
url='https://github.com/rcoh/angle-grinder'
license=('MIT')
depends=('glibc' 'gcc-libs')
makedepends=('git' 'rust')
options=('!lto')
_commit='eba7d7c4e7b42c894a5f7e1a4f66bb140cdf1c76'
source=("$pkgname::git+$url.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname"

  cargo build --frozen --release
}

check() {
  cd "$pkgname"

  cargo test --frozen --release
}

package() {
  cd "$pkgname"

  # binary
  install -vDm755 -t "$pkgdir/usr/bin" target/release/agrind

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
